home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PROGEDIT
/
0748.ZIP
/
MISC
< prev
next >
Wrap
Text File
|
1986-12-29
|
1KB
|
49 lines
/* These contain some miscellaneous routines. */
#define CTRL_C 3
#define CTRL_W 'W'-'A'+1
init()
{
assign_key("copy_ch_above", CTRL_C);
assign_key("copy_wd_above", CTRL_W);
}
copy_ch_above()
{
int c;
if (up()) /* if we're not at the first line */
{ /* go up and get the char above the cursor position */
c = currchar();
down();
if (c == 0) /* check for a NULL character */
c = ' ';
insert(chr(c)); /* insert the string equivalent of the character */
}
}
copy_wd_above()
{
int col1, col2;
string str;
save_position();
str = "";
if (up() && !is_eol()) /* move the cursor up */
{
col1 = currcol(); /* save the starting column */
while (!is_eol() && currchar() == ' ') /* move to 1st char of word */
right();
while (!is_eol() && currchar() != ' ') /* move to end of word */
right();
col2 = currcol(); /* get current column */
if (col2 > col1) /* extract the word */
str = substr(currline(), col1, col2 - col1);
}
restore_position();
insert(str);
}